<template>
	<view class="page">
		<view>
			<radio-group>
				<view class="radio-item" 
				v-for="(item, index) in items" 
				:key="item.value"
				@click="current = index"
				>
					<span>{{item.value}}x{{item.value}}格子 积分：{{item.value}}分</span>
					<radio :value="item.value" :checked="index === current" />
				</view>
			</radio-group>
		</view>
		
		<button type="primary" @click="toGame()">设置完成</button>
		
	</view>
</template>
<script>
	
	var _self
	
	export default {
		data() {
			return {
				items: [{
						value: '8',
						bombNumber: '10',
					},
					{
						value: '10',
						bombNumber: '16',
					},
					{
						value: '12',
						bombNumber: '23',
					},
					{
						value: '15',
						bombNumber: '40',
					},
					{
						value: '18',
						bombNumber: '52',
					},
					{
						value: '20',
						bombNumber: '64',
					},
					{
						value: '25',
						bombNumber: '100',
					}
				],
				current: 0
			}
		},
		onLoad() {
			_self = this
			// console.log(this.$store.state.new_colum)
			for (var i = 0; i < this.items.length; i++) {
				if(parseInt(this.items[i].value) == this.$store.state.new_colum){
					this.current = i
				}
			}
		},
		onShow() {
			//打开webSocket
			// if(!_self.$store.state.start_timeId){
			// 	utils.connectSocketInit()
			// }
		},
		methods: {
			toGame(){
				this.$store.commit("setColum",parseInt(this.items[this.current].value))
				this.$store.commit("setBombNumber",parseInt(this.items[this.current].bombNumber))
				uni.reLaunch({
					url:"../index/index?colum="+this.items[this.current].value
					+"&bombNumber="+this.items[this.current].bombNumber
				})
			}
		}
	}
</script>

<style>
	@import url("setting.css");
</style>
